using GameFramework;
using UnityEngine;

namespace StarForce
{
    public class CreateGroundManager
    { 
        public CreateGroundManager()
        {
            
        }
        /// <summary>
        /// 加载地板
        /// </summary>
        /// <param name="position">地板生成位置</param>
        /// <param name="type">地板类型</param>
        public void LoadGround(Vector3 position, GroundType type)
        {
            LoadGround(position, (int) type);
        }

        /// <summary>
        /// 加载地板
        /// </summary>
        /// <param name="position">地板生成位置</param>
        /// <param name="type">地板类型</param>
        public void LoadGround(Vector3 position, int type)
        {
            switch (type)
            {
                case 2 : GameEntry.Entity.ShowGround(new GroundData(GameEntry.Entity.GenerateSerialId(), type, position, type));
                    break;
                case 3 : GameEntry.Entity.ShowDeathGround(new DeathGroundData(GameEntry.Entity.GenerateSerialId(), type, position, type));
                    break;
                case 4 : GameEntry.Entity.ShowMoveGround(new MoveGroundData(GameEntry.Entity.GenerateSerialId(), type, position, type));
                    break;
                case 5 : GameEntry.Entity.ShowFractureGround(new FractureGroundData(GameEntry.Entity.GenerateSerialId(), type, position, type));
                    break;
            }
        }

        /// <summary>
        /// 生成道具
        /// </summary>
        /// <param name="location"></param>
        public void LoadProp(Vector3 location)
        {
            int propType = 0;
            double random = Utility.Random.GetRandomDouble();
            if (random<0.3)
            {
                propType = 0;
            }
            else if (random<0.7)
            {
                propType = 1;
            }
            else
            {
                propType = 2;
            }

            GameEntry.Entity.ShowProp(new PropData(GameEntry.Entity.GenerateSerialId(), 6,
                location, propType));
        }
    }
}